<?
/** @file
 * @author Andrzej Mararok Wasiak (mararok@gmail.com)
 */
 
/** System errors support
 */
function ErrorHandler($errno,$errstr,$errfile,$errline) {
   if (!(error_reporting()&$errno)) {
      return;
   }

   switch ($errno) {
      case E_USER_ERROR :
         MainLogger::log(Logger::FATAL_ERROR,addslashes(" FATAL ERROR: [$errno] $errstr on [$errline] in [$errfile]"));
         exit(1);
         break;

      case E_USER_WARNING :
         MainLogger::log(Logger::WARNING,addslashes("WARNING: [$errno] $errstr"));
         break;

      case E_USER_NOTICE :
         MainLogger::log(Logger::INFO,addslashes("NOTICE: [$errno] $errstr"));
         break;

      case E_PARSE :
         MainLogger::log(Logger::FATAL_ERROR,addslashes("Parse: [$errno] $errstr on [$errline] in [$errfile]"));
         break;

      case E_NOTICE:
         return true;
         break;

      default :
         MainLogger::log(Logger::INFO,addslashes("Unknown: [$errno] $errstr on [$errline] in [$errfile]"));
         break;
   }
   
   if (!(DEBUG_MODE))
      echo '</br>There was an error in the operation, we working at this !!!</br>';
   else 
      echo "</br>".$errstr."</br>";
   return true;
}

set_error_handler('ErrorHandler');
?>